package com.zengzhi.mydesignmode.strategymode;

/**
 * @author xiejiawei
 * @Date 2021-08-14
 * @Time 22:12
 *  测试类
 *
 */
public class MiniDuckSimulator {
    public static void main (String[] args){
        // 实例化MallardDuck 对应的行为在构造器中实例化 委托给performFly执行
        Duck mallardDuck = new MallardDuck();
        //改变鸭子的行为
       /* mallardDuck.setFlyBehavior(new FlyNoWay());
        mallardDuck.setQuackBehavior(new Squeak());*/
        mallardDuck.performFly();
        mallardDuck.performQuack();
        // 实例化模型鸭子，并改变其行为，使其具有火箭动力飞行的能力
        Duck modelDuck = new ModelDuck();
        modelDuck.setFlyBehavior(new FlyRocketPowered());
        modelDuck.performFly();


    }
}
